package com.model.xmlElement;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.model.xmlElement.input.Input;
import com.model.xmlElement.output.Output;
import com.sort.DataColumnOutputSort;

/**
 * *********************************************
 * @author Administrator
 * @FileName XMLElements.java
 * @Description XML配置文件对应的集合
 **********************************************
 */
@XmlRootElement(name = "root")
@XmlAccessorType(XmlAccessType.FIELD)
public class DataColumns extends ArrayList<DataColumn> implements Serializable{
	public static final Logger LOG = LoggerFactory.getLogger(DataColumns.class);
	private static final long serialVersionUID = 1L;
	
	private File file;
	@XmlElement(name = "dateFilter")
	private DataFilter dataFilter;
	@XmlElement(name = "input")
	private Input input;
	@XmlElement(name = "output")
	private Output output;
	@XmlElementWrapper(name = "pageDefaults")
	@XmlElement(name = "pageDefault")
	private List<PageDefault> pageDefaults;
	@XmlElementWrapper(name = "datacolumns")
	@XmlElement(name = "datacolumn")
	public List<DataColumn> getDataColumns() {
		return this;
	}
	
	/**
	 * XMLElements排序
	 */
	public void sortDataColumnOutputs(){
		List<DataColumnOutput> dataColumnOutputs = new ArrayList<DataColumnOutput>();
		for(DataColumn dataColumn : this){
			dataColumnOutputs.add(dataColumn.getDataColumnOutput());
		}
		Collections.sort(dataColumnOutputs, new DataColumnOutputSort());
	}
	
	public File getFile() {
		return file;
	}
	public void setFile(File file) {
		this.file = file;
	}
	public DataFilter getDataFilter() {
		return dataFilter;
	}
	public void setDataFilter(DataFilter dataFilter) {
		this.dataFilter = dataFilter;
	}
	public Input getInput() {
		return input;
	}
	public void setInput(Input input) {
		this.input = input;
	}
	public Output getOutput() {
		return output;
	}
	public void setOutput(Output output) {
		this.output = output;
	}
	public List<PageDefault> getPageDefaults() {
		return pageDefaults;
	}
	public void setPageDefaults(List<PageDefault> pageDefaults) {
		this.pageDefaults = pageDefaults;
	}
	
}